﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;
namespace DAO
{
    public class NganHangDA
    {
        public static NganHang GetByID(int maID)
        {
            NganHang loai = null;
            SqlConnection cn = DataProvider.Connect();
            SqlCommand cmd = new SqlCommand("Proc_NganHang_GetById", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@maNganHang", maID));
            SqlDataReader dataReader = cmd.ExecuteReader();
            if (dataReader.Read())
            {
                loai = new NganHang();
                loai.MaNganHang = maID;
                loai.TenNganHang = Convert.ToString(dataReader["TenNganHang"]);
                loai.TrangThai = Convert.ToInt32(dataReader["TrangThai"]);
            }
            cn.Close();
            return loai;
        }

        public static DataTable GetAll()
        {
            DataTable dt = new DataTable();
            SqlConnection cn = DataProvider.Connect();
            SqlCommand cmd = new SqlCommand("Proc_NganHang_GetAll", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            cn.Close();
            return dt;
        }
    }
}
